# -*- coding: utf-8 -*-
# @File  : csdn_request.py
# @Author: yh
# @Date  : 2019/8/9
# @Software: PyCharm
import user_agent
import urllib.request as ur


def getRequest(url):
    """
    发送请求，获得请求响应
    :param url: 请求地址
    :return: 返回当前请求地址后获得内容信息
    """
    return ur.Request(
        url=url,
        headers={
            'User-Agent': user_agent.get_user_agent_pc(),
        }
    )


def getProxyOpener():
    """
    启用代理ip
    :return:获取open对象
    """
    proxy_handler = ur.ProxyHandler(
        {
            'http': '119.23.110.100:8000',
        }
    )
    return ur.build_opener(proxy_handler)
